package com.wuseguang.springcloud.controller;


import com.wuseguang.springcloud.service.StudentExchangeDetailsService;
import com.wuseguang.springcloud.util.Result;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 学生积分信息以及兑换详情表 前端控制器
 * </p>
 *
 * @author 
 * @since 2020-06-19
 */
@RestController
@RequestMapping("/brands")
public class StudentExchangeDetailsController {

    private Logger logger = LoggerFactory.getLogger(this.getClass());

    @Autowired
    private StudentExchangeDetailsService studentExchangeDetailsServiceImpl;

    /**
     *学生积分信息以及兑换详情
     * @param deviceid 班牌id
     * @param studentId 学生id
     * @return
     */
    @RequestMapping("/findStudentExchangeDetails")
    public Result findStudentExchangeDetails(@RequestParam(value = "deviceid") String deviceid,
                                             @RequestParam(value = "studentId") String studentId){
            logger.info("学生积分信息以及兑换详情");
            return studentExchangeDetailsServiceImpl.findStudentExchangeDetails(deviceid,studentId);
    }

    /**
     * 学生兑换奖品
     * @param deviceid 班牌id
     * @param studentId 学生id
     * @param prizeId 奖品id
     * @return
     */
    @RequestMapping("/addStudentExchangeDetails")
    public Result addStudentExchangeDetails(@RequestParam(value = "deviceid") String deviceid,
                                            @RequestParam(value = "studentId") String studentId,
                                            @RequestParam(value = "studentName") String studentName,
                                            @RequestParam(value = "prizeId") String prizeId){
        logger.info("学生兑换奖品");
        return studentExchangeDetailsServiceImpl.addStudentExchangeDetails(deviceid,studentId,prizeId,studentName);
    }

    /**
     * 查询奖品列表
     * @param deviceid
     * @return
     */
    @RequestMapping("/findPrizeList")
    public Result findPrizeList(@RequestParam(value = "deviceid") String deviceid){
        logger.info("查询奖品列表");
        return studentExchangeDetailsServiceImpl.findPrizeList(deviceid);
    }

    /**
     * 查询兑换记录
     * @param deviceid
     * @param studentId
     * @return
     */
    @RequestMapping("/findRecordList")
    public Result findRecordList(@RequestParam(value = "deviceid") String deviceid,
                                 @RequestParam(value = "studentId") String studentId){
        logger.info("查询兑换记录");
        return studentExchangeDetailsServiceImpl.findRecordList(deviceid,studentId);
    }

}

